import requests
import execjs

headers = {
    "Accept": "application/json, text/javascript",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cache-Control": "no-cache",
    "Connection": "keep-alive",
    "Origin": "https://www.pinduoduo.com",
    "Pragma": "no-cache",
    "Referer": "https://www.pinduoduo.com/",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-site",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
    "sec-ch-ua-mobile": "?0",
}
url = "https://apiv2.pinduoduo.com/api/gindex/tf/query_tf_goods_info"

with open('拼多多.js', encoding='utf-8') as f:
    js_code = f.read()

anti_content = execjs.compile(js_code).call('get_data')
print(anti_content)

params = {
    "tf_id": "TFRQ0v00000Y_13394",
    "page": "1",
    "size": "100",
    "anti_content": anti_content
}

response = requests.get(url, headers=headers, params=params)

print(response.text)
print(response)
